exports.customerHistoryBrowseRecord = (req, res) => {

    var restfulParams = req.routeInfo.restfulParams;

    var resultData = {};

    var c_openid = restfulParams.c_openid;

    var skip = restfulParams.skip == undefined ? 0 : restfulParams.skip;

    var limit = restfulParams.limit == undefined ? 20 : restfulParams.limit;

    //查询客户浏览记录
    function customerHistoryBrowse(cb) {

        R.SEND_HTTP(
            req,
            res,
            {
                url: config.external_server.apiAddress + "/organization/search_art_product_user_read_record/apurr_openid/" + c_openid+"/sort_order/apurr_id-desc"+ "/skip/" + skip + "/limit/" + limit,
                method: 'POST',
                data: {
                    fields: ['apurr_id', 'apurr_create_time', 'apurr_read_count', 'apuur_mcid'].join(",")
                }
            },
            function (data) {
                console.log(data);

                resultData.customerHistoryBrowse = data.result.data;

                cb();

            }
        )
    }

    function queryForEachBrowsContent(cb) {

        F.SerialEach(resultData.customerHistoryBrowse, function (item, index, callback) {

            //查询浏览内容
            function browsContent(eachCb) {

                R.SEND_HTTP(
                    req,
                    res,
                    {
                        url: CORE_APIConfig.coreAPI.artMediaCommunicationSearch.Request_Api_Url + "/mc_is_delete/0/mc_id/" + item.apuur_mcid,
                        method: 'POST',
                        data: {
                            fields: ['mc_title'].join(",")
                        }
                    },
                    function (data) {
                        console.log(data);

                        if(data.result.data.length>0){
                            item.browseContent = data.result.data[0].mc_title;
                        }else{
                            item.browseContent = '';
                        }

                        eachCb();

                    }
                )
            }

            F.Parallel([
                browsContent,
            ], () => {
                callback();
            })

        }, cb)

    }

    F.Serial([
        customerHistoryBrowse,
        queryForEachBrowsContent,
    ], () => {
        RES.successResponse(res, resultData);
    })


}